package org.example.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping(produces = "application/json;charset=utf-8")
public class UserController {

    @RequestMapping("/getsession")
    public String getSession(String name, String pass, HttpSession session){
            session.setAttribute("name",name);  //session存入到对应redis
            return "ok";
    }

    @RequestMapping("/getname")
    public String getName(HttpSession session){
        String name = (String)session.getAttribute("name");  //直接从redis中获得
        System.out.println("name="+name);
        return name;
    }
}
